﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PDX.Notification
{
    /// <summary>
    /// Notifies subscribers when state may have changed via the <see cref="NotificationRaised"/> event.
    /// Also allows clients to publish a notification by calling <see cref="Notify"/>.
    /// </summary>
    public interface INotificationManager
    {
        /// <summary>
        /// Transactionally raises the <see cref="NotificationRaised"/> event.
        /// </summary>
        void Notify();

        /// <summary>
        /// Begins a disposable transaction.
        /// Clients will probably want to use a "using" statement.
        /// </summary>
        /// <returns></returns>
        Transaction BeginDisposableTransaction();

        /// <summary>
        /// Gets a value indicating whether there is transaction in progress.
        /// </summary>
        /// <value>
        /// 	<c>true</c> if there is transaction in progress; otherwise, <c>false</c>.
        /// </value>
        bool IsTransactionInProgress { get; }

        /// <summary>
        /// Gets the transaction number.
        /// This is incremented every transaction.
        /// </summary>
        int TransactionNumber { get; }

        /// <summary>
        /// Signal to subscribers that state may have changed.
        /// For example, property values on the viewmodel.
        /// </summary>
        event EventHandler NotificationRaised;
    }
}
